//
//  EFReturnGoodsTypeCell.m
//  EnjogFood
//
//  Created by guocheng on 2017/6/10.
//  Copyright © 2017年 wf. All rights reserved.
//

#import "EFReturnGoodsTypeCell.h"
#import "EFReturnGoodsTypeView.h"
#import "EFChooseReturnGoodsViewController.h"

@interface EFReturnGoodsTypeCell()

@property(strong,nonatomic)UILabel* titleLabel;
@property(strong,nonatomic)UIButton* addBtn;
@property(strong,nonatomic)UIView* lineView;

@property(assign,nonatomic)NSInteger type;

@end

@implementation EFReturnGoodsTypeCell

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if(self){
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.contentView.backgroundColor = [UIColor clearColor];
        self.backgroundColor =  [UIColor clearColor];
        [self initView];
    }
    return self;
}

- (void)initView{
    [self.contentView addSubview:self.titleLabel];
    [self.contentView addSubview:self.addBtn];
    [self.contentView addSubview:self.lineView];
}


- (void)setObject:(EFReturnGoodsTypeView *)item{
    [super setObject:item];
    self.type = item.type;
    [self.titleLabel setText:item.title];
}

-(void)onClickAddBtn{
    if(self.addblock != NULL){
        self.addblock(self.type);
    }
}


-(UILabel *)titleLabel{
    if(_titleLabel == NULL){
        _titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, 100, 17)];
        _titleLabel.font = [UIFont systemFontOfSize:15];
        _titleLabel.textColor = kBlack333;
        _titleLabel.left = 20;
        _titleLabel.top = 17;
    }
    return _titleLabel;
}

-(UIButton *)addBtn{
    if(_addBtn == NULL){
        _addBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 60, 17)];
        _addBtn.left = kScreenWidth - _addBtn.width - 20;
        _addBtn.top =  17;
        [_addBtn setImage:IMG(@"addto_icon_returnschoose") forState:UIControlStateNormal];
        [_addBtn setImage:IMG(@"addto_icon_returnschoose") forState:UIControlStateSelected];
        [_addBtn setTitle:@"添加" forState:UIControlStateNormal];
        _addBtn.titleLabel.font = [UIFont systemFontOfSize:15];
        [_addBtn setTitleColor:kBlack999 forState:UIControlStateNormal];
        _addBtn.imageEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 30);
        _addBtn.titleEdgeInsets = UIEdgeInsetsMake(0, 5, 0, 0);
        
        [_addBtn addTarget:self action:@selector(onClickAddBtn) forControlEvents:UIControlEventTouchUpInside];
    }
    
    return _addBtn;
}

-(UIView *)lineView{
    if(_lineView == NULL){
        _lineView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth - 40, 1)];
        _lineView.backgroundColor = RGBCOLOR(0xECECEC);
        _lineView.left = 20;
        _lineView.top = self.titleLabel.bottom + 20;
    }
    return _lineView;
}

@end
